//
//  BaseMvvmController.m
//  jobClient
//
//  Created by 小细菌 on 2021/1/20.
//  Copyright © 2021 YL1001. All rights reserved.
//

#import "BaseMvvmController.h"

@interface BaseMvvmController ()
@property (nonatomic, strong ) TrainingViewModel *viewModel;
@end

@implementation BaseMvvmController


+ (instancetype)allocWithZone:(struct _NSZone *)zone {
    BaseMvvmController *viewController = [super allocWithZone:zone];
    @weakify(viewController)
    [[viewController rac_signalForSelector:@selector(viewDidLoad)] subscribeNext:^(id x) {
        @strongify(viewController)
        [viewController gx_setupUI];
        [viewController gx_bindViewModel];
        [viewController.viewModel performSelector:@selector(gx_viewDidLoad)];
    }];
    return viewController;
}

- (instancetype)initWithViewModel:(TrainingViewModel *)viewModel {
    self = [super init];
    if (self) {
        _viewModel = viewModel;
        _viewModel.delegate = self;
    }
    return self;
}

- (void)setViewModel:(TrainingViewModel *)viewModel{
    _viewModel = viewModel;
    _viewModel.delegate = self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
   
   
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [_viewModel performSelector:@selector(gx_viewWillAppear)];
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [_viewModel performSelector:@selector(gx_viewWillDisappear)];
}
- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    [_viewModel performSelector:@selector(gx_viewDidDisappear)];
}
- (void)gx_setupUI {}

- (void)gx_bindViewModel {}

- (void)dealloc {
//    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

@end
